import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { WalkthroughSubType } from "./WalkthroughSubType";
import { HTMLUtil } from "../../../../com/gengine/utils/HTMLUtil";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { DailyItemConfig } from "../../resource/DailyItemConfig";
import { Cache } from "../../cache/Cache";
import { ObjCreate } from "../common/ObjCreate";
import { GTextFormat } from "../../../common/GTextFormat";
import { FontUtil } from "../../../common/font/FontUtil";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { TilePanel } from "../equipment/TilePanel";
import { WalkthroughItemRenderer } from "./WalkthroughItemRenderer";
import { ImagesConst } from "../../resource/ImagesConst";
import { EffectManager } from "../../manager/EffectManager";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
import { LineBox } from "../guide/LineBox";
type int = number;
//class WalkthroughTypeRenderer
    
    export  class WalkthroughTypeRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            this._descTxt.htmlText = arg1.index + "." + arg1.desc;
            this._subtype = arg1.type;
            this._typeTip = WalkthroughSubType.getDescBySubType(this._subtype);
            if (!(this._typeTip == null) && !(this._typeTip == "")) 
            {
                this._descTxt.toolTipData = HTMLUtil.addColor(WalkthroughSubType.getDescBySubType(this._subtype), "#ffffff");
            }
            this._dataProvider = new DataProvider(DailyItemConfig.instance.getDailyArrayByWalkthroughSubType(this._subtype, Cache.instance.role.entityInfo.level));
            this._itemListPanel.dataProvider = this._dataProvider;
            this._itemListPanel.drawNow();
            this._backType = this._subtype;
            if (this._subtype != WalkthroughSubType.LevelDaily) 
            {
                this.onFlashTimeCompleteHandler(null);
            }
            else 
            {
                this.showLineBox();
            }
            return;
        }

        /* internal  */init(): void
        {
            this._descTxt = ObjCreate.createGTextField("", 0, 0, 220, 20, this, new GTextFormat(FontUtil.songtiName, 12, GlobalStyle.color2Uint, true));
            this._descTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._itemListPanel = new TilePanel();
            this._itemListPanel.columnWidth = 405;
            this._itemListPanel.rowHeight = 40;
            this._itemListPanel.setSize(405, 120);
            this._itemListPanel.move(0, 20);
            this._itemListPanel.setStyle("cellRenderer", WalkthroughItemRenderer);
            this.addChild(this._itemListPanel);
            ObjCreate.createBg(0, 130, 400, 2, this, ImagesConst.SplitLine);
            return;
        }

        /* internal  */showLineBox(): void
        {
            if (Cache.instance.role.entityInfo.level != 36) 
            {
                this.removeLineBox();
            }
            else 
            {
                if (this._secTimer == null) 
                {
                    this._secTimer = new Object /* flash.utils.Timer */(1000);
                    this._secTimer.repeatCount = 5;
                    this._secTimer.addEventListener(flash.events.TimerEvent.TIMER_COMPLETE, this.onFlashTimeCompleteHandler);
                }
                this._secTimer.reset();
                this._secTimer.start();
                if (this._lineBox == null) 
                {
                    this._lineBox = EffectManager.getLineBox(65, 27);
                    this._lineBox.x = 262;
                    this._lineBox.y = 18;
                }
                if (!this.contains(this._lineBox)) 
                {
                    this.addChild(this._lineBox);
                }
            }
            return;
        }

        /* internal  */onFlashTimeCompleteHandler(arg1: Object /* flash.events.TimerEvent */): void
        {
            if (this._secTimer) 
            {
                this._secTimer.stop();
            }
            this.removeLineBox();
            return;
        }

        /* internal  */removeLineBox(): void
        {
            if (this._lineBox) 
            {
                if (this.contains(this._lineBox)) 
                {
                    this.removeChild(this._lineBox);
                }
            }
            return;
        }

        /* internal */ /* var */_descTxt: GTextFiled;

        /* internal */ /* var */_subtype: int;

        /* internal */ /* var */_backType: int;

        /* internal */ /* var */_itemListPanel: TilePanel;

        /* internal */ /* var */_lineBox: LineBox;

        /* internal */ /* var */_secTimer: Object /* flash.utils.Timer */;

        /* internal */ /* var */_dataProvider: DataProvider;

        /* internal */ /* var */_typeTip: string;
    }
